package com.dawn.seckilldemo.config;

import com.dawn.seckilldemo.pojo.User;

//用来存储拦截器获取的user对象.
public class UserContext {
    //每个线程都有自己的threadlocal，存在这里不容易混乱
    private static ThreadLocal<User> userHolder = new ThreadLocal<>();

    public static void setUser(User user){
        userHolder.set(user);
    }

    public static User getUser(){
        return userHolder.get();
    }
}
